package com.ruoyi.system.config;

import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

/**
 * @program: ruoyi
 * @description: 支付宝支付的相关配置类
 * @author: yanghua
 * @create: 2020-09-22 17:56
 **/
@Component
public class AlipayConfig {
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号,开发时使用沙箱提供的APPID，生产环境改成自己的APPID
    public static String APP_ID = "2021000116674174";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String APP_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDRMu8kN7oogZ/uhmPnY6qLD91DfJBwP8iBlFaYVUzvNrM7CQqcWzUgdx2asgz7KzsinKfWbcpji5QVCaKoKRq8yJE16ZDKGnAvcgxT/GRbMnGZGfbIG0DrmFcvaSWwEpKvSvDpt/z5VkbfrSzIqleLx9K5FwhS4PZevUMX0BQuDM8nL/azVvDkqw5Ta8ZmI/4dOm3O6Qo9awJiWodp9G6Xp60+bZe7hdiZQgq0sIbA9Iy4J1PneHKcJk46GY6CxtQla2u6T4Km3+y1k9ismHFdI9kc3BtX0KnvFM01n9hSeliu+di+qm3d8IpI99KqevklLwS63omNxGXJlEiWdK3lAgMBAAECggEAawvUIMU/RcDmlIhCEMIIH3ZzszfHNRj+QYglM3fakUF9PwUmX9GwArfQ9zqKt+9sKA7fNzMg8AUZNhajG8dEvjsnSt4ET9Ztd2m1czhgJeZPCJenlseTVbqzSjhUp58pXfdMBVw3X2LNi2Ey3E+F0qniYwGtKbOhfeL8tO+tk83eqIM5iXEe2rVaLe960xzxg61nJrfiL2yyxzpW9PiIJPbUvGIAKCSkkJKrz4LO9wsC6f40h2Zz1QSFiQlzIdsYzqLyNXHTa4Rd9+XEh1k9uzP57hZFe3VwfbG05DReX6OnjchedXKRqH073K/iZ6CAp5psaUXZPnPUjUM8+Jw31QKBgQD5Sd2oMnE0mostRTK18VgL3KjFTLfTpWpyn0yABWZnmRZylpTQMBvsoZEseVIw1RYIB5LtXaA5ZQyeFNpu1PHzF/G9oEwqLSBqMKYZkd/mvimKkTdOUDHPLYLRrLEoisvy971rtijOdiMBnveMKfc1c0L3b+OeIhjCsiZGFgeRhwKBgQDW1MPQQBi4MQXhE4X8BBfAv/SAj1Rr0HphZQsgagBpWjI4j/Zs0r7jaoBtuS07NjcSJuclqWM/r2Qss8MsFObOTld7VXEqrX3g00ypf/JvjFC4eMlkn8dAx/Na47obrxW6KF6pZyCUr+mndaCdh/8d+rW8ulkQQlM8ykDibuPQMwKBgAS6ZOzawBDqWXdrV5Hh2PSoo77SPK5T9dfks5O+Bnoyih10Q7BLKUxsqA864dcxQ3C1jBDadL6B7yJUbOwrN8ePjbM2BhvKrVG2SIA1pxR+SNVq+ayPktJGH7QQXW/Sahnanwoa810vGmzecf2Dkj++RufghGWsaeHPdTBhHJWjAoGBANG7A7PSb4+apH+43KxNnpbZj6zWwPdEn8VnrPYnJmGz4aWgvlY9ZIiGl/0GtGbDJf59pln5RWCOLUEK+jaV7UJp7zQEFSgyGdsczhIITDmkhcWifhLTfeX7jtQj0LRoOND1ynydpowiNPz8dCJ2+5RcB4LJdlvONI77cV7eHWBLAoGBAIlJFXohZ7FEE4ZDxu+4CDqpzen/YO07EOXtQYeNfpomaOc/RwHnpYYngTKuz9sViw7oOzd/F7Z5bwxHeVSrBO61bSmO5BohhIg7+GXfvtY+zA4rz9/LTzDEwTT31eGwE8mbapK9BzxGE+AsCHQ4EqbNY5/GUluLwq1F01OlK39S";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。你自己的支付宝公钥，注意是支付宝公钥，不是应用公钥
    public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjvpst2qG+CDLC93Nu10DTfWKcUiodc6ZvToTva+GsBSVVmBTna3T/2moD4NSGqiAVHc59NVphupPYTC0O17z0zvUK03QLHE+LWci81qQYDzpjI23Xz+h/DpKfO07vvOmGVXZt7blPAtLqfoBBc5PKiYDtwLeHy+0qmBKpEKszAjFQWyEnqaEyWenUK18ImIL+P/HyqyP8OOhE8mOJlSH0ZjMpBGwP7PQy+HEtWhlo7CUKtDOIDj1lrOCB0wdr0ToNv4lYUCX9tsImH8vHrIHGvLH+iulVa4/eFNuD6l/6R1QpCeYIAG9cGNk+8nN8jzhhy6tiJdcdeY/2fC/ng5/pwIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://yincha.com";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问(其实就是支付成功后返回的页面)
    public static String return_url = "http://yincha.com";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String CHARSET = "utf-8";

    // 支付宝网关，这是沙箱的网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "F:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     *
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis() + ".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
